package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 石小俊
 * @date 2023年06月30日 11:15
 */
@WebServlet(urlPatterns = "/life2",loadOnStartup = 2,initParams = {
        @WebInitParam(name = "name",value = "admin")
})
public class LifeTwoServlet extends HttpServlet {
    @Override
    public void init() throws ServletException {
        System.out.println("*************注解版初始化方法*************");
        String name = getInitParameter("name");
        System.out.println("name:"+name);
    }

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("注解版执行核心业务逻辑");
        String name = getInitParameter("name");
        System.out.println("name:"+name);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行post请求方法");
    }
    @Override
    public void destroy() {
        System.out.println("正在销毁");
    }

}
